/*
 *
 *      Copyright (c) 2018-2025, nart All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the pig4cloud.com developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: nart
 *
 */

package com.nai365.nart.product.api.feign;

import com.nai365.nart.common.core.constant.SecurityConstants;
import com.nai365.nart.common.core.constant.ServiceNameConstants;
import com.nai365.nart.common.core.util.R;
import com.nai365.nart.product.entity.SkuInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Collection;
import java.util.List;

/**
 * @author nart
 * @date 2018/6/28
 */
@FeignClient(contextId = "remoteSkuService", value = ServiceNameConstants.PRODUCT_SERVICE)
public interface RemoteSkuService {

	/**
	 * 根据spu id 查询可用 sku 列表
	 * <p>
	 * 可用sku:没有质押、没有合成、没有回收
	 * </p>
	 *
	 * @param spuId spu id
	 * @return sku列表
	 */
	@GetMapping("/skuinfo/my/{spuId}/{status}")
	R<List<SkuInfo>> findMySkuBySpuIdAndStatus(@PathVariable("spuId") Long spuId, @PathVariable("status") Integer status);

	/**
	 * 根据sku id list查询sku
	 *
	 * @param skuIds sku id list
	 * @param from   内部调用类型
	 * @return sku List
	 */
	@PostMapping("/skuinfo/infos")
	R<List<SkuInfo>> infos(@RequestBody Collection<Long> skuIds, @RequestHeader(SecurityConstants.FROM) String from);

	/**
	 * 修改SKu
	 *
	 * @param skuInfo SkuInfo
	 * @return sku列表
	 */
	@PutMapping("/skuinfo")
	R<Boolean> updateById(@RequestBody SkuInfo skuInfo);

	/**
	 * 修改SKu,内部调用
	 *
	 * @param skuInfo SkuInfo
	 * @return sku列表
	 */
	@PutMapping("/skuinfo/inner")
	R<Boolean> updateByIdInner(@RequestBody SkuInfo skuInfo, @RequestHeader(SecurityConstants.FROM) String from);

	/**
	 * 锁定一个可用的sku,用于合成
	 *
	 * @param spuId spu id
	 * @return SkuInfo
	 */
	@PutMapping("/skuinfo/lock/{spuId}")
	R<SkuInfo> lockSkuInfo(@PathVariable("spuId") Long spuId);

	/**
	 * 锁定一个可用的sku,用于合成
	 *
	 * @param skuInfo spu id
	 * @return SkuInfo
	 */
	@PutMapping("/skuinfo/unlock")
	R<SkuInfo> unLockSkuInfo(@RequestBody SkuInfo skuInfo);


	/**
	 * 批量更新Sku
	 *
	 * @param skuInfoList sku列表
	 * @return sku列表
	 */
	@PutMapping("/skuinfo/updateBatch")
	R<List<SkuInfo>> updateBatch(@RequestBody List<SkuInfo> skuInfoList);

	/**
	 * 通过id查询sku信息
	 *
	 * @param skuId id
	 * @return R
	 */
	@GetMapping("/skuinfo/{skuId}")
	R<SkuInfo> getById(@PathVariable("skuId") Long skuId);

	@GetMapping("/skuinfo/info/{skuId}")
	R<SkuInfo> getByIdInner(@PathVariable("skuId") Long skuId, @RequestHeader(SecurityConstants.FROM) String from);

	@PutMapping("/skuinfo/findSkuInfoBySkuId/{skuId}")
	SkuInfo findSkuInfoBySkuId(@PathVariable("skuId") Long skuId, @RequestHeader(SecurityConstants.FROM) String from);

}
